package org.come.Frame;

import com.tool.tcpimg.UIUtils;
import org.come.Jpanel.HuangJpanel;
import org.come.until.FormsManagement;

import javax.swing.*;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class HuangJframe extends JInternalFrame implements MouseListener {
    private int first_x;
    private int first_y;
    private HuangJpanel huangJpanel=new HuangJpanel();
    public static HuangJframe getHuangJframe () {
        return (HuangJframe)FormsManagement.getInternalForm(160).getFrame();
    }
    public HuangJframe()throws Exception{
        this.setContentPane(this.huangJpanel);
        this.setBorder(BorderFactory.createEmptyBorder());
        ((BasicInternalFrameUI)this.getUI()).setNorthPane((JComponent)null);
        this.setBounds(280, 70, 300, 128);
        this.pack();
        this.setVisible(false);
        this.setBackground(UIUtils.Color_BACK);
        this.setDefaultCloseOperation(3);
        this.addMouseListener(this);
        this.addMouseMotionListener(new MouseMotionListener() {
            public void mouseMoved(MouseEvent e) {
            }

            public void mouseDragged(MouseEvent e) {
                if (HuangJframe.this.isVisible()) {
                    int x = e.getX() - HuangJframe.this.first_x;
                    int y = e.getY() - HuangJframe.this.first_y;
                    HuangJframe.this.setBounds(x + HuangJframe.this.getX(), y + HuangJframe.this.getY(), HuangJframe.this.getWidth(), HuangJframe.this.getHeight());
                }

            }
        });


    }
    public void mouseClicked(MouseEvent e) {
    }

    public void mousePressed(MouseEvent e) {
        if (e.isMetaDown()) {
            FormsManagement.HideForm(160);
        } else {
            FormsManagement.Switchinglevel(160);
        }

        this.first_x = e.getX();
        this.first_y = e.getY();
    }

    public void mouseReleased(MouseEvent e) {
    }

    public void mouseEntered(MouseEvent e) {
    }

    public void mouseExited(MouseEvent e) {
    }

    public int getFirst_x() {
        return first_x;
    }

    public void setFirst_x(int first_x) {
        this.first_x = first_x;
    }

    public int getFirst_y() {
        return first_y;
    }

    public void setFirst_y(int first_y) {
        this.first_y = first_y;
    }

    public HuangJpanel getHuangJpanel() {
        return huangJpanel;
    }

    public void setHuangJpanel(HuangJpanel huangJpanel) {
        this.huangJpanel = huangJpanel;
    }
}
